package piwan.gui;

import javax.media.opengl.GL;

import piwan.Vector2;


public class GameGui {
	static public void renderRect(GL gl, Vector2 v1, Vector2 v2) {
		gl.glBegin(GL.GL_QUADS);
		gl.glTexCoord2d(0.0,1.0);
		gl.glVertex2d(v1.x,v1.y);
		gl.glTexCoord2d(1.0,1.0);
		gl.glVertex2d(v2.x,v1.y);
		gl.glTexCoord2d(1.0,0.0);
		gl.glVertex2d(v2.x,v2.y);
		gl.glTexCoord2d(0.0,0.0);
		gl.glVertex2d(v1.x,v2.y);
		gl.glEnd();
	}
	
	static public void prepareGuiRender(GL gl, boolean useTexture) {
		gl.glDisable(GL.GL_LIGHTING);
		gl.glDisable(GL.GL_DEPTH_TEST);
		if(useTexture)
			gl.glEnable(GL.GL_TEXTURE_2D);
		else
			gl.glDisable(GL.GL_TEXTURE_2D);
		gl.glEnable(GL.GL_BLEND);
		gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
		gl.glMatrixMode(GL.GL_PROJECTION);
		gl.glLoadIdentity();
		gl.glMatrixMode(GL.GL_MODELVIEW);
		gl.glLoadIdentity();
	}
	
	static public String ntroop(int n ){
		if(n==1)
			return "1 troop";
		else
			return n+ " troops";
	}
}
